package exsun.jt808.data.config.jt808;

import exsun.jt808.data.config.Qingdao.QingdaoMsgIdConfig;

import java.util.concurrent.ConcurrentHashMap;

/*
消息id与topic的关系
 */
public class Jt808MsgIdTopicDic {
    private static ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>();
    static{
        map.put(Jt808MsgIdConfig.jsalt12FileMsgId, Jt808ReceiveMsgTopic.fileStream);
        map.put(Jt808MsgIdConfig.alarmAttachmentInfo, Jt808ReceiveMsgTopic.alarmAttachmentInfo);
        map.put(Jt808MsgIdConfig.fileInfoUpload, Jt808ReceiveMsgTopic.fileInfoUpload);
        map.put(Jt808MsgIdConfig.fileUploadFinished, Jt808ReceiveMsgTopic.fileUploadFinished);
        map.put(Jt808MsgIdConfig.fileUploadResponse, Jt808ReceiveMsgTopic.FileUploadResponse);
        // 808
        map.put(Jt808MsgIdConfig.CANData, Jt808ReceiveMsgTopic.CANData);
        map.put(Jt808MsgIdConfig.CollectDataResponse, Jt808ReceiveMsgTopic.CollectDataResponse);
        map.put(Jt808MsgIdConfig.CompressionData, Jt808ReceiveMsgTopic.CompressionData);
        map.put(Jt808MsgIdConfig.DriverInfoUploadResponse, Jt808ReceiveMsgTopic.DriverInfoUploadResponse);
        map.put(Jt808MsgIdConfig.ElectronicWaybill, Jt808ReceiveMsgTopic.ElectronicWaybill);
        map.put(Jt808MsgIdConfig.EventUpload, Jt808ReceiveMsgTopic.EventUpload);
        map.put(Jt808MsgIdConfig.gpsData, Jt808ReceiveMsgTopic.gpsData);
        map.put(Jt808MsgIdConfig.QueryPositionInfoResponse, Jt808ReceiveMsgTopic.QueryPositionInfoResponse);
        map.put(Jt808MsgIdConfig.InfoDemandOrCancelled, Jt808ReceiveMsgTopic.InfoDemandOrCancelled);
        map.put(Jt808MsgIdConfig.EventUpload, Jt808ReceiveMsgTopic.MediaEvent);
        map.put(Jt808MsgIdConfig.mediaData, Jt808ReceiveMsgTopic.mediaData);
        map.put(Jt808MsgIdConfig.MediaQueryResponse, Jt808ReceiveMsgTopic.MediaQueryResponse);
        map.put(Jt808MsgIdConfig.MessageUpLoadText, Jt808ReceiveMsgTopic.MessageUpLoadText);
        map.put(Jt808MsgIdConfig.TakePhotoRightAwayResponse, Jt808ReceiveMsgTopic.TakePhotoRightAwayResponse);
        map.put(Jt808MsgIdConfig.terminalAuthentication, Jt808ReceiveMsgTopic.terminalAuthentication);
        map.put(Jt808MsgIdConfig.TerminalCommonResponse, Jt808ReceiveMsgTopic.TerminalCommonResponse);
        map.put(Jt808MsgIdConfig.TerminalHearBeat, Jt808ReceiveMsgTopic.TerminalHearBeat);
        map.put(Jt808MsgIdConfig.TerminalLogout, Jt808ReceiveMsgTopic.TerminalLogout);
        map.put(Jt808MsgIdConfig.TerminalPositionInfoUpload_0x0704, Jt808ReceiveMsgTopic.TerminalPositionInfoUpload);
        map.put(Jt808MsgIdConfig.TerminalPositionInfoUpload_0x6002, Jt808ReceiveMsgTopic.TerminalPositionInfoUpload);
        map.put(Jt808MsgIdConfig.TerminalQueryParamResponse, Jt808ReceiveMsgTopic.TerminalQueryParamResponse);
        map.put(Jt808MsgIdConfig.TerminalQueryPropResponse, Jt808ReceiveMsgTopic.TerminalQueryPropResponse);
        map.put(Jt808MsgIdConfig.terminalRegister, Jt808ReceiveMsgTopic.terminalRegister);
        map.put(Jt808MsgIdConfig.TerminalRSAPublicKey, Jt808ReceiveMsgTopic.TerminalRSAPublicKey);
        map.put(Jt808MsgIdConfig.UpgradeCompleteResopnse, Jt808ReceiveMsgTopic.UpgradeResponse);
        map.put(Jt808MsgIdConfig.VehicleControlResponse, Jt808ReceiveMsgTopic.VehicleControlResponse);
        map.put(Jt808MsgIdConfig.DataUpTransmission,Jt808ReceiveMsgTopic.UplinkPassThrough);

        map.put(Jt808MsgIdConfig.SetParameters, Jt808DistributeMsgTopic.SetParameters_Send);
        map.put(Jt808MsgIdConfig.QuerySpecifiedParameters, Jt808DistributeMsgTopic.QuerySpecifiedParameters_Send);
        map.put(Jt808MsgIdConfig.QueryParameters, Jt808DistributeMsgTopic.QueryParameters_Send);
        map.put(Jt808MsgIdConfig.QueryPositionInfo, Jt808DistributeMsgTopic.QueryPositionInfo_Send);
        map.put(Jt808MsgIdConfig.QueryTerminalProperties, Jt808DistributeMsgTopic.QueryTerminalProperties_Send);
        map.put(Jt808MsgIdConfig.Text, Jt808DistributeMsgTopic.Text_Send);
        map.put(Jt808MsgIdConfig.TakePhotoRightAway, Jt808DistributeMsgTopic.TakePhotoRightAway_Send);
        map.put(Jt808MsgIdConfig.QueryServerTimeResponse, Jt808DistributeMsgTopic.QueryServerTimeResponse_send);
        map.put(Jt808MsgIdConfig.QueryAreaOrLineData,Jt808DistributeMsgTopic.QueryAreaOrLineData_send);

        map.put(Jt808MsgIdConfig.mediaFileList,Jt808DistributeMsgTopic.QueryMediaList_Send);
        map.put(Jt808MsgIdConfig.DataDownTransmission,Jt808DistributeMsgTopic.IssueOSPF_Send);

        map.put(Jt808MsgIdConfig.IllegalCarCheck,Jt808DistributeMsgTopic.IllegalCarCheck_Send);


        //青岛协议
        map.put(Jt808MsgIdConfig.HandleIssueSend, Jt808DistributeMsgTopic.HandleIssue_send);
        map.put(Jt808MsgIdConfig.ControlSwitchDefinition, Jt808DistributeMsgTopic.ControlSwitchDefinition_Send);
        map.put(Jt808MsgIdConfig.ControlSwitchSort, Jt808DistributeMsgTopic.ControlSwitchSort_Send);
        map.put(Jt808MsgIdConfig.ControlSwitchStatus, Jt808DistributeMsgTopic.ControlSwitchStatus_Send);
        map.put(Jt808MsgIdConfig.ControlSwitchStatusSort, Jt808DistributeMsgTopic.ControlSwitchStatusSort_Send);
        map.put(Jt808MsgIdConfig.AddPolygonArea, Jt808DistributeMsgTopic.AddPolygonArea_Send);
        map.put(Jt808MsgIdConfig.DeletePolygonArea, Jt808DistributeMsgTopic.DeletePolygonArea_Send);
        map.put(Jt808MsgIdConfig.SortPolygonArea, Jt808DistributeMsgTopic.SortPolygonArea_Send);
        map.put(Jt808MsgIdConfig.AddRoute, Jt808DistributeMsgTopic.AddRoute_Send);
        map.put(Jt808MsgIdConfig.DeleteRoute, Jt808DistributeMsgTopic.DeleteRoute_Send);
        map.put(Jt808MsgIdConfig.SortRoute, Jt808DistributeMsgTopic.SortRoute_Send);
        map.put(Jt808MsgIdConfig.LimitLeftIssue, Jt808DistributeMsgTopic.LimitLeftIssue_Send);
        map.put(Jt808MsgIdConfig.LimitSpeedIssue, Jt808DistributeMsgTopic.LimitSpeedIssue_Send);
        map.put(Jt808MsgIdConfig.LockCar, Jt808DistributeMsgTopic.LockCar_Send);
        map.put(Jt808MsgIdConfig.DriverFace, Jt808DistributeMsgTopic.DriverFace_Send);
        map.put(Jt808MsgIdConfig.DriverMsgSort, Jt808DistributeMsgTopic.DriverMsgSort_Send);
        map.put(Jt808MsgIdConfig.DriverContrastResultUpload, Jt808DistributeMsgTopic.DriverContrastResult_upload);
        map.put(Jt808MsgIdConfig.DriverContrastResult, Jt808DistributeMsgTopic.DriverContrastResultRes);
        map.put(Jt808MsgIdConfig.DeviceInput, Jt808DistributeMsgTopic.DeviceInput_Send);
        map.put(Jt808MsgIdConfig.DeviceInputResponse, Jt808DistributeMsgTopic.DeviceInput_Response);
        map.put(Jt808MsgIdConfig.RemoteUpgrade, Jt808DistributeMsgTopic.RemoteUpgrade_send);
        map.put(Jt808MsgIdConfig.DeviceVersionQuery, Jt808DistributeMsgTopic.DeviceVersionQuery_send);
        map.put(Jt808MsgIdConfig.DeviceVersionReporting, Jt808ReceiveMsgTopic.DeviceVersionReporting);

        map.put(Jt808MsgIdConfig.RealtimeMediaUploadReq, Jt808DistributeMsgTopic.RealtimeMediaUploadReq_Send);
        map.put(Jt808MsgIdConfig.RealtimeMediaUploadCmd, Jt808DistributeMsgTopic.RealtimeMediaUploadCmd_Send);
        map.put(Jt808MsgIdConfig.QueryMediaList, Jt808DistributeMsgTopic.QueryMediaList_Send);
        map.put(Jt808MsgIdConfig.HisMediaUploadReq, Jt808DistributeMsgTopic.HisMediaUploadReq_Send);
        map.put(Jt808MsgIdConfig.HisMediaUploadCmd, Jt808DistributeMsgTopic.HisMediaUploadCmd_Send);
        map.put(Jt808MsgIdConfig.FileUploadReq, Jt808DistributeMsgTopic.FileUploadReq_Send);
        map.put(Jt808MsgIdConfig.FileUploadCmd, Jt808DistributeMsgTopic.FileUploadCmd_Send);
        map.put(Jt808MsgIdConfig.AutoCalibration, Jt808DistributeMsgTopic.AutoCalibration);
        map.put(Jt808MsgIdConfig.AutoCalibrationResponse, Jt808ReceiveMsgTopic.AutoCalibrationResponse);
        map.put(QingdaoMsgIdConfig.driverPictureDownLoadResponse, Jt808ReceiveMsgTopic.driverPictureDownLoadResponse);
    }

    public static String getMsgTopic(Integer msgId){
        if(!map.containsKey(msgId))return "default";
        return map.get(msgId);
    }

    public static Integer getMsgId(String topic){
        for (Integer msgId: map.keySet()) {
            if(map.get(msgId).equals(topic)){
                return msgId;
            }
        }
        return null;
    }

}
